//  夜巡管理

import r from '@/utils/request';
import type { ResponseType, ListParams, ListResponseType } from '../types';

enum API {
    patrolList = '/patrol/list', // 夜巡管理列表
    patrolAdd = '/patrol/add', // 夜巡管理添加
    patrolDelete = '/patrol/delete', // 夜巡管理删除
    patrolGet = '/patrol/get', // 夜巡管理详情
   DeleteAll = "/patrol/deleteAll",
}

// 列表参数
interface patrolListParams extends ListParams {
    name: string;
    address: string;
    state: string;
    beginDate: string;
    endDate: string;
}

// 列表返回值
type patrolListRes = ListResponseType<{
    id: number;
    address: string;
    addTime: string;
    staffName: string;
    state: string;
    comment: string
}>

export interface patrolId{
    id:number
}
// 获取夜巡管理列表接口
export function patrolListAPI(params: patrolListParams): Promise<patrolListRes> {
    return r.get(API.patrolList, params)
}

// 添加参数
interface patrolAddParams  {
    comment: string;
    address: string;
    state: string;
   
}

// 添加返回值
type patrolAddRes = ResponseType<{
    id: number;
    address: string;
    addTime: string;
    staffName: string;
    state: string;
    comment: string
}>


// 获取添加接口
export function patrolAddAPI(params: patrolAddParams): Promise<patrolAddRes> {
    return r.post(API.patrolAdd, params)
}

// 获取删除接口
export function patrolDeleteAPI(id: number): Promise<ResponseType<string>> {
    return r.delete(API.patrolDelete + '/' + id)
}

// 获取详情接口
export function patrolGetAPI(id: number): Promise<ResponseType<any>> {
    return r.get(API.patrolGet + '/' + id)
}

export function patrolDeleteAllAPI(ids:number[]):Promise<ResponseType<null>> {
    return r.post(API.DeleteAll,ids)
}